package com.java.util;

import com.java.util.pojo.User;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

public class ListGroupMapMap {


    /**
     * 这个是Map-Map
     * @param args
     */
    public static void main(String[] args) {
        List<User> list = new ArrayList<>();

        list.add(new User(12, "aa-1", "111", 1, true));
        list.add(new User(13, "bb-1", "111", 1, true));
        list.add(new User(14, "cc-1", "222", 1, true));

        list.add(new User(121, "aa-2", "111", 2, true));
        list.add(new User(131, "bb-2", "222", 2, true));
        list.add(new User(141, "cc-2", "222", 1, true));


        // peek 是遍历，类似与foreach，不过peek是中间操作，不是终止操作

        // 基于getAssetId分组后，再基于getCity分组
        Map<Integer, Map<String, List<User>>> map = list.stream()
                .peek(a -> a.setStatus(false))
                .collect(Collectors.groupingBy(User::getAssetId,
                        Collectors.groupingBy(User::getCity)
                ));
    }



}
